package com.example.surveyapplication;

import help.Utility;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class SittingResultActivity extends Activity implements OnClickListener {
	Button btnSave;
	TextView lblSignOut;
	Spinner spnStress_SittingResult;
	Spinner spnDepression_SittingResult;
	Spinner spnAnxiety_SittingResult;
	ArrayAdapter<CharSequence> adapterSpinner;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sitting_result);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		
		spnStress_SittingResult = (Spinner) findViewById(R.id.spnStress_SittingResult);
		adapterSpinner = ArrayAdapter.createFromResource(this,
		        R.array.spnStress_TestSetting_array, android.R.layout.simple_spinner_item);
		// Specify the layout to use when the list of choices appears
		adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		// Apply the adapter to the spinner
		spnStress_SittingResult.setAdapter(adapterSpinner);
		
		//
		spnDepression_SittingResult = (Spinner) findViewById(R.id.spnDepression_SittingResult);
		adapterSpinner = ArrayAdapter.createFromResource(this,
		        R.array.spnDepression_TestSetting_array, android.R.layout.simple_spinner_item);
		adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		// Apply the adapter to the spinner
		spnDepression_SittingResult.setAdapter(adapterSpinner);
		
		//
		spnAnxiety_SittingResult = (Spinner) findViewById(R.id.spnAnxiety_SittingResult);
		adapterSpinner = ArrayAdapter.createFromResource(this,
		        R.array.spnAnxiety_TestSetting_array, android.R.layout.simple_spinner_item);
		adapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		// Apply the adapter to the spinner
		spnAnxiety_SittingResult.setAdapter(adapterSpinner);
		
		btnSave = (Button)findViewById(R.id.btnSave_SittingResult);
		lblSignOut = (TextView)findViewById(R.id.lblSignOut_SittingResult);
		
		btnSave.setOnClickListener(this);
		lblSignOut.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.sitting_result, menu);
		return true;
	}

	public void onClick(View view) {
		Intent intent;
		
		switch (view.getId()) {
		case R.id.btnSave_SittingResult:
			intent = new Intent(this, TestActivity.class);
			startActivity(intent);
			finish();
			break;
		case R.id.lblSignOut_SittingResult:
			Utility.signOut();
			intent = new Intent(this, SignInActivity.class);
			startActivity(intent);
			finish();
			break;
		default:
			break;
		}
	}
}
